<template>
	<view class="wrap">
		<view class="table_item" v-for="item in data">
			<view class="item">
				<view class="label">编号</view>
				<view class="info">{{item.codeNo}}</view>
			</view>
			<view class="item">
				<view class="label">服务项目</view>
				<view class="info">{{item.serviceItemName}}</view>
			</view>
			<view class="item">
				<view class="label">数量</view>
				<view class="info">{{item.qty}}</view>
			</view>
			<view class="item">
				<view class="label">原价</view>
				<view class="info">{{item.standardPrice}}</view>
			</view>
			<view class="item">
				<view class="label">货币</view>
				<view class="info"></view>
			</view>
			<view class="item">
				<view class="label">折扣</view>
				<view class="info">{{item.coefficient}}</view>
			</view>
			<view class="item">
				<view class="label">附加费</view>
				<view class="info"></view>
			</view>
			<view class="item">
				<view class="label">净值</view>
				<view class="info">{{item.amount}}</view>
			</view>
			<view class="item">
				<view class="label">税后金额</view>
				<view class="info">{{item.afterTaxed}}</view>
			</view>
		</view>
		<view class="next_box" v-if="trfStatus==13">
			<view class="btn cancel" @tap="submit(0)">拒绝报价</view>
			<view class="btn" @tap="submit(1)">确认报价</view>
		</view>
		<view class="next_box" v-else-if="trfStatus==2">
			<view class="btn gray">已拒绝该报价</view>
		</view>
		<view class="next_box" v-else-if="trfStatus!=1">
			<view class="btn gray">已接受该报价</view>
			<view class="btn" @tap="goList" v-if="trfStatus==15">测试报告</view>
		</view>
	</view>
</template>

<script>
	import {toast} from '@/common/public.js'
	import {mixins} from '@/common/mixins.js'
	export default {
		mixins:[mixins],
		data() {
			return {
				data:[],
				trfId:'',
				weUserId:'',
				trfStatus:'',
				contractFileId:'',
				entry:2
			}
		},
		onLoad(options) {
			this.trfId = options.trfId
			if(uni.getStorageSync('sgs_userId')) {
				this.initData()
			} else {
				this.wxAuth()
			}
		},
		methods: {
			initData() {
				this.weUserId = uni.getStorageSync('sgs_userId')
				uni.showLoading({
					title:'加载中...'
				})
				this.selectQuotationInfoByTrfId()
			},
			selectQuotationInfoByTrfId() {
				let param = {
					trfId:this.trfId,
					weUserId:this.weUserId
				}
				this.$api.selectQuotationInfoByTrfId(param).then(res=>{
					uni.hideLoading()
					if (res.code == 200) {
						this.data = res.data.quotations
						this.trfStatus = res.data.trfStatus
						this.contractFileId = res.data.contractDocFile.id
					} else {
						toast(res.msg)
					}
				})
			},
			submit(condirmedFlag) {
				let param = {
					condirmedFlag:condirmedFlag,
					contractFileId:this.contractFileId,
					trfId:this.trfId,
					weUserId:this.weUserId
				}
				this.$api.quotationConfirmedForWechat(param).then(res=>{
					uni.hideLoading()
					if (res.code == 200) {
						this.selectQuotationInfoByTrfId()
					} else {
						toast(res.msg)
					}
				})
			},
			goList() {
				uni.navigateTo({
					url:`/pages/reportList/reportList?trfId=${this.trfId}`
				})
			}
		}
	}
</script>

<style scoped>
	.wrap{
		padding:10rpx 10rpx 120rpx;
	}
	.table_item{
		margin-bottom: 40rpx;
		background-color: #fbfbfb;
		/* box-shadow: 0 0 8rpx 0 rgba(0,0,0,.1); */
	}
	.item{
		display: flex;
		border:2rpx solid #eee;
		margin-top: -2rpx;
		font-size: 26rpx;
	}
	.label{
		width: 180rpx;
		padding:10rpx;
	}
	.info{
		flex:1;
		min-width: 0;
		padding:10rpx;
		word-wrap: break-word;
		border-left: 2rpx solid #eee;
	}
	.next_box{
		position: fixed;
		left:0;
		bottom:0;
		z-index:9999999;
		width:100%;
		padding:20rpx;
		display: flex;
		box-sizing: border-box;
		background-color: #fff;
	}
	.btn{
		width: 300rpx;
		height: 70rpx;
		text-align: center;
		line-height: 70rpx;
		margin: 0 auto;
		color: #fff;
		font-size: 26rpx;
		background-color: #ff6600;
	}
	.cancel{
		background-color: #fff;
		border:2rpx solid #eee;
		color:#333;
	}
	.gray{
		background-color: #f4f4f4;
		color:#333;
	}
</style>
